﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AspNetCs.Bll;
using AspNetCs.Model;
using AspNetCs.Common;
using AspNetCs.Config;
using System.Data;
using System.Data.SqlClient;
using AspNetCs.Enumerations;

public partial class Master_ArticleReback : Admin_BasePage
{
    protected City city = new City();
    AspNetCs.Bll.Article bll = CreateArticle_BLL.CreateNew;
    protected void Page_Load(object sender, EventArgs e)
    {
        IsExit();
        if (!IsPostBack)
        {
            dataBind();
        }

    }

    public string GetNetMuTypeName(string id)
    {
        string str = "";
        try
        {
            int NetMuType = StringHelper.isNumber_int(id);
            if (NetMuType > -1)
            {
                NetMuTypeEnum NetMu = (NetMuTypeEnum)NetMuType;
                str = NetMu.ToString();
            }
        }
        catch (Exception ex)
        {
            str = ex.Message;
            CustomException cus = new CustomException(ex);
        }
        return str;

    }



    protected void dataBind()
    {
        string cmdText = "select ar.*,ac.className from Article as ar inner join ArticleClass as ac on ar.ClassID=ac.classId where ar.IsDel=1 order by ArticleId desc";
        AspNetCs.Common.DataPagesOperate operate = new DataPagesOperate();

        operate.BindRepeater(cmdText, AspNetPager1, "ArticleId desc", "ArticleId", rptNetMuList);


    }


    protected void rptNetMuList_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        LinkButton lbtn = null;
        try
        {
            int count = 0;
            string id = "";
            int NetMuId = 0;
            if (e.CommandName == "Reback")
            {
                lbtn = e.Item.FindControl("lbtnReback") as LinkButton;
                id = lbtn.CommandArgument;
                NetMuId = Convert.ToInt32(id);
                bool bo = false;

                bo = bll.RebackArticle(NetMuId);
                dataBind();

            }
            else if (e.CommandName == "delete")
            {
                lbtn = e.Item.FindControl("btn_del") as LinkButton;
                id = lbtn.CommandArgument;
                NetMuId = Convert.ToInt32(id);
                bool bo = false;

                count = bll.PhyicDeleteArticle(NetMuId);
                bo = count > 0 ? true : false;
                if (bo)
                {
                    showMessage("deleteSucce", "删除成功");
                    dataBind();
                }
                else
                {
                    showMessage("deleteFaith", "删除失败");
                    dataBind();
                }
            }

        }
        catch (Exception ex)
        {
            new CustomException(ex);
        }
    }

    protected void AspNetPager1_PageChanged(object sender, EventArgs e)
    {
        dataBind();
    }
}
